package com.qfedu.bookstores.dao.impl;

import com.qfedu.bookstores.dao.BaseDao;
import com.qfedu.bookstores.dao.IUserDao;
import com.qfedu.bookstores.entity.User;

//先继承BaseDao的目的就是因为这个类里面已经做好实现
public class IUserDaoImpl extends BaseDao implements IUserDao {
    @Override
    public User queryUserByUserName(String username) {
        String sql = "select id,username,password,email from t_user where username=?";
        return queryForOne(User.class, sql, username);
    }

    @Override
    public int saveUser(User user) {
        String sql = "insert into t_user(username,password,email) values(?,?,?)";
        return update(sql, user.getUsername(),user.getPassword(),user.getEmail());
    }

    @Override
    public User queryUserByUserNameAndPassword(String username, String password) {
        String sql = "select * from t_user where username = ? and password = ?";
        return queryForOne(User.class, sql, username,password);
    }
}
